/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.hl7.v3.impl;

import java.util.Collection;
import java.util.List;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.BasicFeatureMap;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;

import org.hl7.v3.StrucDocCaption;
import org.hl7.v3.StrucDocFootnote;
import org.hl7.v3.StrucDocFootnoteRef;
import org.hl7.v3.StrucDocLinkHtml;
import org.hl7.v3.StrucDocSub;
import org.hl7.v3.StrucDocSup;
import org.hl7.v3.V3Package;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Struc Doc Caption</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.hl7.v3.impl.StrucDocCaptionImpl#getMixed <em>Mixed</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocCaptionImpl#getGroup <em>Group</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocCaptionImpl#getLinkHtml <em>Link Html</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocCaptionImpl#getSub <em>Sub</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocCaptionImpl#getSup <em>Sup</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocCaptionImpl#getFootnote <em>Footnote</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocCaptionImpl#getFootnoteRef <em>Footnote Ref</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocCaptionImpl#getID <em>ID</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocCaptionImpl#getLanguage <em>Language</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocCaptionImpl#getStyleCode <em>Style Code</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class StrucDocCaptionImpl extends EObjectImpl implements StrucDocCaption {
	/**
	 * The cached value of the '{@link #getMixed() <em>Mixed</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMixed()
	 * @generated
	 * @ordered
	 */
	protected FeatureMap mixed;

	/**
	 * The default value of the '{@link #getID() <em>ID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getID()
	 * @generated
	 * @ordered
	 */
	protected static final String ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getID() <em>ID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getID()
	 * @generated
	 * @ordered
	 */
	protected String iD = ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getLanguage() <em>Language</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLanguage()
	 * @generated
	 * @ordered
	 */
	protected static final String LANGUAGE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getLanguage() <em>Language</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLanguage()
	 * @generated
	 * @ordered
	 */
	protected String language = LANGUAGE_EDEFAULT;

	/**
	 * The default value of the '{@link #getStyleCode() <em>Style Code</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStyleCode()
	 * @generated
	 * @ordered
	 */
	protected static final List<String> STYLE_CODE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getStyleCode() <em>Style Code</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStyleCode()
	 * @generated
	 * @ordered
	 */
	protected List<String> styleCode = STYLE_CODE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected StrucDocCaptionImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return V3Package.eINSTANCE.getStrucDocCaption();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FeatureMap getMixed() {
		if (mixed == null) {
			mixed = new BasicFeatureMap(this, V3Package.STRUC_DOC_CAPTION__MIXED);
		}
		return mixed;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FeatureMap getGroup() {
		return (FeatureMap)getMixed().<FeatureMap.Entry>list(V3Package.eINSTANCE.getStrucDocCaption_Group());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<StrucDocLinkHtml> getLinkHtml() {
		return getGroup().list(V3Package.eINSTANCE.getStrucDocCaption_LinkHtml());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<StrucDocSub> getSub() {
		return getGroup().list(V3Package.eINSTANCE.getStrucDocCaption_Sub());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<StrucDocSup> getSup() {
		return getGroup().list(V3Package.eINSTANCE.getStrucDocCaption_Sup());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<StrucDocFootnote> getFootnote() {
		return getGroup().list(V3Package.eINSTANCE.getStrucDocCaption_Footnote());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<StrucDocFootnoteRef> getFootnoteRef() {
		return getGroup().list(V3Package.eINSTANCE.getStrucDocCaption_FootnoteRef());
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getID() {
		return iD;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setID(String newID) {
		String oldID = iD;
		iD = newID;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.STRUC_DOC_CAPTION__ID, oldID, iD));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getLanguage() {
		return language;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLanguage(String newLanguage) {
		String oldLanguage = language;
		language = newLanguage;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.STRUC_DOC_CAPTION__LANGUAGE, oldLanguage, language));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public List<String> getStyleCode() {
		return styleCode;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStyleCode(List<String> newStyleCode) {
		List<String> oldStyleCode = styleCode;
		styleCode = newStyleCode;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.STRUC_DOC_CAPTION__STYLE_CODE, oldStyleCode, styleCode));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case V3Package.STRUC_DOC_CAPTION__MIXED:
				return ((InternalEList<?>)getMixed()).basicRemove(otherEnd, msgs);
			case V3Package.STRUC_DOC_CAPTION__GROUP:
				return ((InternalEList<?>)getGroup()).basicRemove(otherEnd, msgs);
			case V3Package.STRUC_DOC_CAPTION__LINK_HTML:
				return ((InternalEList<?>)getLinkHtml()).basicRemove(otherEnd, msgs);
			case V3Package.STRUC_DOC_CAPTION__SUB:
				return ((InternalEList<?>)getSub()).basicRemove(otherEnd, msgs);
			case V3Package.STRUC_DOC_CAPTION__SUP:
				return ((InternalEList<?>)getSup()).basicRemove(otherEnd, msgs);
			case V3Package.STRUC_DOC_CAPTION__FOOTNOTE:
				return ((InternalEList<?>)getFootnote()).basicRemove(otherEnd, msgs);
			case V3Package.STRUC_DOC_CAPTION__FOOTNOTE_REF:
				return ((InternalEList<?>)getFootnoteRef()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case V3Package.STRUC_DOC_CAPTION__MIXED:
				if (coreType) return getMixed();
				return ((FeatureMap.Internal)getMixed()).getWrapper();
			case V3Package.STRUC_DOC_CAPTION__GROUP:
				if (coreType) return getGroup();
				return ((FeatureMap.Internal)getGroup()).getWrapper();
			case V3Package.STRUC_DOC_CAPTION__LINK_HTML:
				return getLinkHtml();
			case V3Package.STRUC_DOC_CAPTION__SUB:
				return getSub();
			case V3Package.STRUC_DOC_CAPTION__SUP:
				return getSup();
			case V3Package.STRUC_DOC_CAPTION__FOOTNOTE:
				return getFootnote();
			case V3Package.STRUC_DOC_CAPTION__FOOTNOTE_REF:
				return getFootnoteRef();
			case V3Package.STRUC_DOC_CAPTION__ID:
				return getID();
			case V3Package.STRUC_DOC_CAPTION__LANGUAGE:
				return getLanguage();
			case V3Package.STRUC_DOC_CAPTION__STYLE_CODE:
				return getStyleCode();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case V3Package.STRUC_DOC_CAPTION__MIXED:
				((FeatureMap.Internal)getMixed()).set(newValue);
				return;
			case V3Package.STRUC_DOC_CAPTION__GROUP:
				((FeatureMap.Internal)getGroup()).set(newValue);
				return;
			case V3Package.STRUC_DOC_CAPTION__LINK_HTML:
				getLinkHtml().clear();
				getLinkHtml().addAll((Collection<? extends StrucDocLinkHtml>)newValue);
				return;
			case V3Package.STRUC_DOC_CAPTION__SUB:
				getSub().clear();
				getSub().addAll((Collection<? extends StrucDocSub>)newValue);
				return;
			case V3Package.STRUC_DOC_CAPTION__SUP:
				getSup().clear();
				getSup().addAll((Collection<? extends StrucDocSup>)newValue);
				return;
			case V3Package.STRUC_DOC_CAPTION__FOOTNOTE:
				getFootnote().clear();
				getFootnote().addAll((Collection<? extends StrucDocFootnote>)newValue);
				return;
			case V3Package.STRUC_DOC_CAPTION__FOOTNOTE_REF:
				getFootnoteRef().clear();
				getFootnoteRef().addAll((Collection<? extends StrucDocFootnoteRef>)newValue);
				return;
			case V3Package.STRUC_DOC_CAPTION__ID:
				setID((String)newValue);
				return;
			case V3Package.STRUC_DOC_CAPTION__LANGUAGE:
				setLanguage((String)newValue);
				return;
			case V3Package.STRUC_DOC_CAPTION__STYLE_CODE:
				setStyleCode((List<String>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case V3Package.STRUC_DOC_CAPTION__MIXED:
				getMixed().clear();
				return;
			case V3Package.STRUC_DOC_CAPTION__GROUP:
				getGroup().clear();
				return;
			case V3Package.STRUC_DOC_CAPTION__LINK_HTML:
				getLinkHtml().clear();
				return;
			case V3Package.STRUC_DOC_CAPTION__SUB:
				getSub().clear();
				return;
			case V3Package.STRUC_DOC_CAPTION__SUP:
				getSup().clear();
				return;
			case V3Package.STRUC_DOC_CAPTION__FOOTNOTE:
				getFootnote().clear();
				return;
			case V3Package.STRUC_DOC_CAPTION__FOOTNOTE_REF:
				getFootnoteRef().clear();
				return;
			case V3Package.STRUC_DOC_CAPTION__ID:
				setID(ID_EDEFAULT);
				return;
			case V3Package.STRUC_DOC_CAPTION__LANGUAGE:
				setLanguage(LANGUAGE_EDEFAULT);
				return;
			case V3Package.STRUC_DOC_CAPTION__STYLE_CODE:
				setStyleCode(STYLE_CODE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case V3Package.STRUC_DOC_CAPTION__MIXED:
				return mixed != null && !mixed.isEmpty();
			case V3Package.STRUC_DOC_CAPTION__GROUP:
				return !getGroup().isEmpty();
			case V3Package.STRUC_DOC_CAPTION__LINK_HTML:
				return !getLinkHtml().isEmpty();
			case V3Package.STRUC_DOC_CAPTION__SUB:
				return !getSub().isEmpty();
			case V3Package.STRUC_DOC_CAPTION__SUP:
				return !getSup().isEmpty();
			case V3Package.STRUC_DOC_CAPTION__FOOTNOTE:
				return !getFootnote().isEmpty();
			case V3Package.STRUC_DOC_CAPTION__FOOTNOTE_REF:
				return !getFootnoteRef().isEmpty();
			case V3Package.STRUC_DOC_CAPTION__ID:
				return ID_EDEFAULT == null ? iD != null : !ID_EDEFAULT.equals(iD);
			case V3Package.STRUC_DOC_CAPTION__LANGUAGE:
				return LANGUAGE_EDEFAULT == null ? language != null : !LANGUAGE_EDEFAULT.equals(language);
			case V3Package.STRUC_DOC_CAPTION__STYLE_CODE:
				return STYLE_CODE_EDEFAULT == null ? styleCode != null : !STYLE_CODE_EDEFAULT.equals(styleCode);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (mixed: ");
		result.append(mixed);
		result.append(", iD: ");
		result.append(iD);
		result.append(", language: ");
		result.append(language);
		result.append(", styleCode: ");
		result.append(styleCode);
		result.append(')');
		return result.toString();
	}

} //StrucDocCaptionImpl
